import { IOptionClass } from '@/hooks/useGetClassIds'
import { Empty } from 'antd'
export const searchConfig = ({
  ProDevSeason,
  classIdOptions,
  settinyClassIds,
  handleClassIdChange,
  SupplierOption,
  handleSearchSupplier,
}: {
  ProDevSeason: IOptionItem[]
  classIdOptions: IOptionClass[]
  settinyClassIds: React.Dispatch<React.SetStateAction<string[]>>
  handleClassIdChange: (_: React.Key[], data: IOptionClass[]) => string[]
  SupplierOption: IOptionItem[]
  handleSearchSupplier: (newVal: string) => void
}): IItemArray[] => {
  return [
    {
      label: '开发季',
      name: 'seasonId',
      type: 'Select',
      option: ProDevSeason,
      rules: [
        {
          required: true,
          message: '请选择开发季',
        },
      ],
    },
    {
      label: '订单类型',
      name: 'orderTypes',
      type: 'Select',
      option: [
        { label: '首单', value: 0 },
        { label: '返单', value: 1 },
      ],
      rules: [
        {
          required: true,
          message: '请选择订单类型',
        },
      ],
      config: {
        optionFilterProp: 'label',
        mode: 'multiple',
        maxTagCount: 'responsive',
        showSearch: true,
        filterOption: true,
      },
    },
    {
      name: 'queryClassIdList',
      label: '款式分类',
      type: 'Cascader',
      option: classIdOptions,
      placeholder: '请选择款式分类',
      config: {
        changeOnSelect: true,
        onChange: handleClassIdChange,
        onClear: () => settinyClassIds([]),
        fieldNames: { label: 'className', value: 'classConfigId', children: 'childrenList' },
      },
    },
    {
      name: 'querySupplierIdList',
      label: '供应商',
      type: 'Select',
      option: SupplierOption,
      config: {
        suffixIcon: null,
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: false,
        mode: 'multiple',
        maxTagCount: 'responsive',
        onSearch: handleSearchSupplier,
        notFoundContent: <Empty description="请输入内容搜索" image={Empty.PRESENTED_IMAGE_SIMPLE} />,
      },
    },
  ]
}
